package org.jetlinks.pro.koudai.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.crud.generator.Generators;
import org.hswebframework.web.validator.CreateGroup;

import javax.persistence.Column;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.sql.JDBCType;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 实验课程信息
 *
 * @author zhoukun
 * @since 1.3
 */
@Getter
@Setter
@Table(name = "k_question", indexes = {
    @Index(name = "idx_question_id", columnList = "id")
})
public class QuestionEntity extends GenericEntity<String> {

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题名称")
    private String questionName;

//    @Column(length = 64, nullable = false)
//    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
//    @Schema(description = "试题归属课程")
//    private String courseId;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题归属实验")
    private String experimentId;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题类型")
    private String questionType;

    @Column
    @ColumnType(jdbcType = JDBCType.LONGVARCHAR)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题题干")
    private String questionTitle;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题分数")
    private String questionScore;

    @Column
    @ColumnType(jdbcType = JDBCType.LONGVARCHAR)
    @JsonCodec
    @Schema(description = "试题选项")
    private Map<String, Object> choices;

    @Column(length = 64, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "试题答案")
    private String questionAnswer;


    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Date createTime;

    @Column
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Date updateTime;



}
